/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlacciones.ejb3.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.sql.DataSource;

/**
 *
 * @author Vanessa
 */
@Stateless
public class ValorizarAccionDAOBean implements ValorizarAccionDAOLocal {
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add Operation")

    public String sp_valorizarAcciones( String ano, String mes  )throws SQLException
     {
        String ban = "";
        try {
            Connection cn = this.dsComercial.getConnection();
            CallableStatement cs = cn.prepareCall("{ call sp_generarValorizaciones( ?, ?, ? ) }");
            cs.setString(1, ano);
            cs.setString(2, mes );
            cs.registerOutParameter( 3, java.sql.Types.VARCHAR);
            cs.execute();
            ban = cs.getString( 3 );
        } catch (SQLException ex) {
            ban = ex.getMessage();
            Logger.getLogger( ValorizarAccionDAOBean.class.getName()).log(Level.SEVERE, null, ex);
            throw ex;
        }
        return ban;
    }

    @Resource(name="jdbc/Comercial")
    DataSource dsComercial;
 
}
